﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TPOJ.Model.ForumMessage>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Message Details 
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2><%= Html.Encode(Model.Title) %></h2>
    <p>Posted by <%= Html.ActionLink(Html.Encode(TPOJ.Web.Utils.GetUserName(Model.AccountId)), "Details", "Account", new { id = TPOJ.Web.Utils.GetUserName(Model.AccountId) }, new { target="_blank" }) %> at <%= Html.Encode(String.Format("{0:g}", Model.DateTime)) %> on <%= Html.ActionLink("Problem "+Model.ProblemId, "Details", "Problem", new { id = Model.ProblemId }, new { target = "_blank" }) %></p>
    <p><%= Html.Encode(Model.MessageContent).Replace("\n", "<br />") %></p>
    
    <% var followMessages = (IEnumerable<TPOJ.Model.ForumMessage>)ViewData["FollowMessages"]; %>
    <% if (followMessages.Count() > 0) { %>
    <h3>Followed by:</h3>
    <br />
    <ul id="treeview">
        <% Html.RenderPartial("~/Views/Shared/TreeNode.ascx", followMessages); %>
    </ul>
    <% } %>
        <% using (Html.BeginForm())
       {%>
       <%= Html.HiddenFor(model=>model.ProblemId) %>
       <%= Html.HiddenFor(model=>model.UniqueId) %>
        <fieldset>
            <legend>Post your reply</legend>
            
            <% if (!Request.IsAuthenticated) {%>
        <h3>Please Login First.</h3>
        <%} else {%>

            <div class="editor-label">
                Title
            </div>
            <div class="editor-field">
                <%= Html.TextBox("Title","Re:" + Model.Title)%>
                <%= Html.ValidationMessageFor(model => model.Title)%>
            </div>
            
            <div class="editor-label">
                Content
            </div>
            <div class="editor-field">
                <%= Html.TextArea("MessageContent", "\n\n\n---------------------\n>" + Model.MessageContent.Replace("\n","\n>"), new { rows = 10, cols = 80 })%>
                <%= Html.ValidationMessageFor(model => model.MessageContent)%>
            </div>
            
            <p>
                <input type="submit" value="Post" />
            </p>
        <% } %>
        </fieldset>

    <% } %>


</asp:Content>

